local fangzhu = fk.CreateSkill {
  name = "lingling__fangzhu",
}

Fk:loadTranslationTable {
  ["lingling__fangzhu"] = "放逐",
  [":lingling__fangzhu"] = "当你受到伤害后，你可以令一名其他角色摸两张牌并翻面，若其背面朝上则改为令其弃置两张牌。",
  ["#lingling__fangzhu"] = "放逐：你可以令一名其他角色翻面，然后其摸两张牌",
}

fangzhu:addEffect(fk.Damaged, {
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(fangzhu.name) and #player.room:getOtherPlayers(player, false) > 0
  end,
  --[[trigger_times = function(self, event, target, player, data)
    return data.damage
  end,]]--
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player, {
      min_num = 1,
      max_num = 1,
      targets = room:getOtherPlayers(player, false),
      skill_name = fangzhu.name,
      prompt = "#lingling__fangzhu",
      cancelable = true,
    })
    if #to > 0 then
      event:setCostData(self, { tos = to })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local to = event:getCostData(self).tos[1]
    if to.dead then return end
    if not to.faceup then
      player.room:askToDiscard(to,{
        max_num = 2,
        min_num = 2,
        skill_name = fangzhu.name,
        cancelable = false,
      })
    else
      to:drawCards(2, fangzhu.name)
    end
    if to.dead then return end
    to:turnOver()
  end,
})

return fangzhu
